#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <queue>
#include <algorithm>
#define REP(i,n) for(int i=0;i<int(n);++i)

using namespace std;
typedef pair<int,int> pii;

#define x first
#define y second
struct state
{
	pii p;
	int pre;
	int cnt;
	state(pii a,int b,int c){p=a,pre=b,cnt=c;}
};

const int inf = 1<<29;
const int dir[][2]={{0,1},{0,-1},{1,0},{-1,0}};
int n,m,k;
char map[60][60];
int done[60][60];
int prei[30];
pii ps,pt;

void printAns()
{
	queue<state> q;
	q.push(state(ps,0,0));
	while(!q.empty())
	{
		state st = q.front();q.pop();
		int x = st.p.x, y = st.p.y;
		if(st.p==pt)
		{

		}
		if(st.pre > k) continue;
		REP(i,4)
		{
			int tx = x + dir[i][0], ty = y + dir[i][1];
			if(tx<0||ty<0||tx>=n++||ty>=m) continue;
			int nextPrei = prei[map[tx][ty]-'a'];
			int nextCnt = st.cnt + ((nextPrei&st.pre)!=0)?0:1;
			if(nextCnt < done[tx][ty])
			{
				done[tx][ty] = nextCnt;
				q.push(state(pii(tx,ty),nextPrei|st.pre,nextCnt));
			}
		}
	}
}

int main()
{
	REP(i,26) prei[i] = 1<<i;
	while(cin>>n>>m>>k)
	{
		fill(done[0],done[0]+60*60,inf);
		REP(i,n) scanf("%s",map[i]);
		REP(i,n) REP(j,m)
		{
			if(map[i][j]=='S') ps.x=i,ps.y=j,done[i][j]=0;
			if(map[i][j]=='T') pt.x=i,pt.y=j;
		}
		printAns();
	}
	return 0;
}
